/**
 * AppStorage 存储的元素
 */
export default class AppStorageItemData {
  key: string;
  prop: SubscribedAbstractProperty<any>;
  value: any;

  constructor(key: string, prop: SubscribedAbstractProperty<any>, value: any) {
    this.key = key;
    this.prop = prop;
    this.value = value;
  }

  get stringValue() {
    let t = typeof this.value
    if (t == 'undefined') {
      return 'undefined'
    }
    else if (t == 'number' || t == 'boolean') {
      return this.value.toString()
    }
    else if (t == 'object' || t == 'function' || t == 'symbol') {
      return JSON.stringify(this.value)
    }
    else {
      return this.value
    }
  }
}